package com.xpresso.utils.unitTests;

import com.xpresso.utils.email.EmailConfiguration;
import com.xpresso.utils.email.EmailMessage;
import com.xpresso.utils.email.SimpleEmailProvider;
import com.xpresso.utils.exceptions.XpressoException;

import junit.framework.TestCase;

public class TestSimpleEmailProvider extends TestCase {

	public void testEmailProvider(){
		EmailConfiguration conf = new EmailConfiguration();
		conf.setHost("mail.erclab.com");
		conf.setUser("me@erclab.com");
		conf.setPass("themail9");
		conf.setAuthentication(true);
	
		EmailMessage message = new EmailMessage();
		message.setTo(new String[]{"echamussy@gmail.com"});
		message.setFrom("me@erclab.com");
		message.setSubject("Test");
		message.setBody("Testing email provider");		
		
		SimpleEmailProvider ep = new SimpleEmailProvider();
		ep.configure(conf);
		try {
			ep.sendEmail(message);
		} catch (XpressoException e) {
			e.printStackTrace();
			e.getTheException().printStackTrace();
			fail();
		}
		
	}
	
}
